package org.me.app;

import org.me.bean.Student;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {
	private Button login;
	private TextView results;
	int request_Code = 1;
	String tag = "";

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		login = (Button) findViewById(R.id.btn_login);
		login.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				//startActivityForResult(new Intent("org.me.app.LoginActivity"),request_Code);
				startActivity(new Intent("org.me.app.LoginActivity"));

			}
		});
	}

	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (requestCode == request_Code) {
			if (resultCode == RESULT_CANCELED) {
				Log.v(tag, data.getData().toString());
				Toast.makeText(this, data.getData().toString(),
						Toast.LENGTH_SHORT).show();
				// TextView resu = (TextView)findViewById(R.id.tv_results);
				// resu.setText(data.getData().toString());
			} else if (resultCode == RESULT_OK) {
				// Intent data2 = new
				// Intent(LoginActivity.this,StudentProfileActivity.class);

				Student student = data.getExtras().getParcelable(
						"org.me.bean.Student");

				results.setText(student.getStudentName() + "  "
						+ student.getStudentId());
			}
		}
	}

}